<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="no-cache"/>
    <meta http-equiv="Expires" content="-1"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <title>修改个人信息</title>

    <script type="text/javascript">
      Ext.onReady(function(){
              Ext.QuickTips.init();

              var applicantId = <%= session[:applicant_id] %>
              var editInformationForm = new Ext.form.FormPanel({
                    width: screenWidth-330,
                    height: screenHeight-320,
                    //labelAlign: 'top',
                    url:'/applicant/changeInformation',
                    buttonAlign:'center',
                    fileUpload: true,
                    bodyStyle: 'padding:5px',
                    labelWidth:100,
                    waitMsgTarget: true,
                    frame: true,
                    reader:new Ext.data.JsonReader({
                       },[
                       {name:'id'},
                       {name:'name'},
                       {name:'login_id'},
                       {name:'phone'},
                       {name:'mobile'},
                       {name:'email'},
                       {name:'department_name',mapping:'department.name'}
                      ]
                    ),
                    items:[{
                           xtype:'hidden',
                           name:'id',
                           value:''
                     },{
                          layout:'column',
                          items:[{
                              columnWidth:.5,
                              layout:'form',
                              labelAlign: 'top',
                              items:[{
                                  xtype:'textfield',
                                  fieldLabel: '申购人编号',
                                  name: 'login_id',
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '移动电话',
                                  name: 'mobile',
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: 'Email',
                                  name: 'email',
                                  allowBlank:false,
                                  anchor:'90%'
                              }]
                          },{
                              columnWidth:.5,
                              layout:'form',
                              labelAlign: 'top',
                              items:[{
                                  xtype:'textfield',
                                  fieldLabel: '申购人姓名',
                                  name:'name',
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '固定电话',
                                  name: 'phone',
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  fieldLabel: '所属部门',
                                  xtype:'textfield',
                                  name: 'department_name',
                                  allowBlank:false,
                                  anchor:'90%'
                              }]
                          }]
                     }],
                     buttons:[{
                        text:'确定',
                        handler: function(){
                          Ext.MessageBox.confirm('警告','您确定要修改自己的信息么？',function(button){
                            if(button=='yes'){
                                // check form value
                                if (editInformationForm.form.isValid()) {
                                  editInformationForm.form.submit({
                                    method: 'post',
                                    waitMsg: '正在更新个人信息...',
                                    success: function(result, response){
                                      if (response.result.info == "success") {
                                        Ext.MessageBox.alert('消息', '个人信息更新成功');
                                      }else {
                                        Ext.MessageBox.alert('消息', response.result.info);
                                      }
                                    },
                                    failure: function(result, response){
                                      Ext.MessageBox.alert('提示', result.responseText);
                                    }
                                  });
                                }
                                else {
                                  Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                                }
                            }
                          })
                            
                          }
                    }]
                });
          editInformationForm.form.load({
               url: '/applicant/edit?id=' + applicantId,
               success: function(form, action){
               },
               failure: function(form, action){
                  Ext.MessageBox.alert('提示信息', '信息加载失败');
               }
          });
          editInformationForm.render('edit_information_form');
      })
    </script>
  </head>
  <body>
     <div id="edit_information_form"></div>
  </body>
</html>
